package com.ls.socketio.bean;

import lombok.*;

import javax.persistence.*;
import java.util.List;

/**
 * 房间信息
 * @author liShan
 * @date 2019/9/3 11:12
 */
@Getter
@Setter
@ToString
@Entity(name ="room")
public class RoomInfo extends BaseInfo {

    @Id
    @Column(name = "room_id")
    private Long roomId;

    @Column(name = "layer_id")
    private Long layerId;

    @Column(name = "room_num")
    private int roomNum;

    @OneToMany(cascade = CascadeType.DETACH)
    @JoinColumn(name = "room_id")
    private List<RoomBoxInfo> roomBoxInfos;

    @OneToMany(cascade = CascadeType.DETACH)
    @JoinColumn(name = "room_id")
    private List<RoomEnvInfo> envInfos;

    @OneToMany(cascade = CascadeType.DETACH)
    @JoinColumn(name = "room_id")
    private List<RoomAirConditionerInfo> airInfos;

    @OneToMany(cascade = CascadeType.DETACH)
    @JoinColumn(name = "room_id")
    private List<RoomBaseInfo> baseInfos;

    @OneToMany(cascade = CascadeType.DETACH)
    @JoinColumn(name = "room_id")
    private List<RoomLampInfo> lampInfos;

    public RoomInfo() { }

    private RoomInfo(Builder builder) {
        super(builder);
        this.roomId = builder.roomId;
        this.layerId = builder.layerId;
        this.roomNum = builder.roomNum;
        this.envInfos = builder.envInfos;
        this.roomBoxInfos = builder.roomBoxInfos;
        this.airInfos = builder.airInfos;
        this.baseInfos = builder.baseInfos;
        this.lampInfos = builder.lampInfos;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder extends BaseBuilder<Builder>{

        private Long roomId;
        private Long layerId;
        private int roomNum;
        private List<RoomEnvInfo> envInfos;
        private List<RoomBoxInfo> roomBoxInfos;
        private List<RoomAirConditionerInfo> airInfos;
        private List<RoomBaseInfo> baseInfos;
        private List<RoomLampInfo> lampInfos;

        @Override
        Builder self() {
            return this;
        }

        public Builder roomId(Long roomId){
            this.roomId = roomId;
            return this;
        }

        public Builder layerId(Long layerId){
            this.layerId = layerId;
            return this;
        }

        public Builder roomNum(int roomNum){
            this.roomNum = roomNum;
            return this;
        }

        public Builder envInfos(List<RoomEnvInfo> envInfos){
            this.envInfos = envInfos;
            return this;
        }

        public Builder roomBoxInfos(List<RoomBoxInfo> roomBoxInfos){
            this.roomBoxInfos = roomBoxInfos;
            return this;
        }

        public Builder airInfos(List<RoomAirConditionerInfo> airInfos){
            this.airInfos = airInfos;
            return this;
        }

        public Builder baseInfos(List<RoomBaseInfo> baseInfos){
            this.baseInfos = baseInfos;
            return this;
        }

        public Builder lampInfos(List<RoomLampInfo> lampInfos){
            this.lampInfos = lampInfos;
            return this;
        }

        public RoomInfo build() {
            return new RoomInfo(this);
        }

    }


}
